#include "Rp2Effect.h"
#include "Rp2Geometry.h"
#include "Rp2Renderer.h"
#include "Rp2VisibleSet.h"

using namespace Rp2;

RP2_IMPLEMENT_RTTI(Rp2, Effect, Object);
RP2_IMPLEMENT_DEFAULT_NAME_ID(Effect, Object);

//---------------------------------------------------------------------------------------------------
Effect::Effect()
{
}
//---------------------------------------------------------------------------------------------------
Effect::~Effect()
{
}
//---------------------------------------------------------------------------------------------------
void Effect::Draw(Renderer* pkRenderer, Spatial* pkGlobalObject,
        int iMin, int iMax, VisibleObject* akVisible)
{
    // The default drawing function for global effects.  Essentially, this is
    // a local effect applied to all the visible leaf geometry.
	for (int i = iMin; i < iMax; i++)
	{
		if (akVisible[i].IsDrawable())
		{
			Geometry* pkGeometry = (Geometry*)akVisible[i].Object;
            pkGeometry->AttachEffect(this);
            pkRenderer->Draw(pkGeometry);
            pkGeometry->DetachEffect(this);
		}
	}
}
//---------------------------------------------------------------------------------------------------
void Effect::LoadResources (Renderer*, Geometry*)
{
    // Stub for derived classes.
}
//---------------------------------------------------------------------------------------------------
void Effect::ReleaseResources (Renderer*, Geometry*)
{
    // Stub for derived classes.
}
//---------------------------------------------------------------------------------------------------